import Vuex from 'vuex'
import Vue from 'vue';
import state from './state'
import mutations from './mutations'
import getters from './getters'
Vue.use(Vuex)

const abb = store => {
    // 当 store 初始化后调用
    store.subscribe((mutation, state) => {
        console.log(mutation,state)
        window.localStorage.setItem('icicic',JSON.stringify(state.cart))
      // 每次 mutation 之后调用
      // mutation 的格式为 { type, payload }
    })
  }

  const ccc = store => {
    // 当 store 初始化后调用
    store.subscribe((mutation, state) => {
        console.log(mutation,state)
        window.localStorage.setItem('xxx-user',JSON.stringify(state.user))
      // 每次 mutation 之后调用
      // mutation 的格式为 { type, payload }
    })
  }
export default new Vuex.Store({
    strict:true,
    state,
    mutations,
    plugins: [abb,ccc],
    getters,
})